<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<c:import url="../cabecalho.jsp" />
<c:import url="../menu.jsp" />
<div class="col-sm-9 col-sm-offset-3 col-lg-10 col-lg-offset-2 main">
	<div class="row">
		<ol class="breadcrumb">
			<li>
				<a href="#">
					<span class="glyphicon glyphicon-home"></span>
				</a>
			</li>
			<li class="active">
				<fmt:message key="consulta.pecas" />
			</li>
		</ol>
	</div>
	<div class="row">
		<div class="col-lg-12">
			<h1 class="page-header">
				<fmt:message key="consulta.pecas" />
			</h1>
		</div>
	</div>
	<form:form action="consultarPeca" commandName="peca">
		<div class="row">
			<div class="col-lg-10 col-md-10">
				<div class="panel panel-default">
					<div class="panel-heading cab">
						<fmt:message key="filtrodedados" />
					</div>
					<div class="panel-body">
						<div class="col-md-12 col-lg-12">
							<div class="form-group col-md-10 col-lg-10">
								<form:label path="codigo">
									<fmt:message key="codigo" />
								</form:label>
								<form:input cssClass="form-control" path="codigo" id="codigoDaPecaAutocomplete" value="" />
							</div>
							<div class="form-group col-md-2 col-lg-2">
								<button type="submit" class="btn btn-primary direita">
									<fmt:message key="consultar" />
								</button>
							</div>
						</div>
					</div>
					<div class="panel-body">
						<c:if test="${not empty pecasPesquisadas}">
							<div class="col-lg-12">
								<table class="table table-hover">
									<thead>
										<tr>
											<th>
												<fmt:message key="codigo" />
											</th>
											<th>
												<fmt:message key="descricao" />
											</th>
											<th>
												<fmt:message key="disponibilidade" />
											</th>
											<th>
												<fmt:message key="preco" />
											</th>
										</tr>
									</thead>
									<c:forEach items="${pecasPesquisadas}" var="pecaPesquisada">
										<tr>
											<td>${pecaPesquisada.codigo}</td>
											<td>${pecaPesquisada.descricao}</td>
											<td>${pecaPesquisada.disponibilidade}</td>
											<td><fmt:formatNumber value="${pecaPesquisada.preco}" minFractionDigits="2" type="currency"/></td>
										</tr>
									</c:forEach>
								</table>
							</div>
						</c:if>
					</div>
				</div>
			</div>
		</div>
	</form:form>
</div>
<c:import url="../rodape.jsp" />
